package com.arajuuri.catinvaders.fileoperations;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;


/**
 * <p>Title: Cat Invaders</p>
 * <p>Description: A space invaders clone with cats</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author Semi Arajuuri
 * @version 1.0
 */

public class Objects {
  public Objects() {
  }

  public static void writeObjectToFile(Object obj, String fileName){
    try {
        FileOutputStream fos = new FileOutputStream(fileName);
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(obj);
        oos.close();
    }
    catch (Exception e) {}
  }

  public static Object readObjectFromFile(String fileName){
    Object obj=new Object();
    File file=new File(fileName);
    try {
      file.createNewFile();
      FileInputStream fis = new FileInputStream(fileName);
      ObjectInputStream ois = new ObjectInputStream(fis);
      obj = ois.readObject();
      ois.close();
    }
    catch (Exception e) {}
    return obj;
  }

}
